(module gui mzscheme
  (provide (all-defined))
  
  (require (lib "mred.ss" "mred")
           (lib "class.ss")
           (lib "defmacro.ss"))
  
  (define +name+ "S Running Log")
  (define +author+ "Greg Johnston")
  (define +logo+ (make-object bitmap% "images/srl.png" 'png))
  
  (define +font+ (make-object font% 10 'default 'normal 'normal #f 'default))
  (define +left-width+ 150)
  
  (define-macro define-row
    (lambda (name parent)
      `(define ,name (instantiate horizontal-pane% (,parent)))))
  
  (define-macro define-input
    (lambda (name parent)
      `(begin (define ,(string->symbol (string-append (symbol->string name) "-f"))
                (instantiate text-field% ("" ,parent)))
              (define (,name) ,(string->symbol (string-append (symbol->string name) "-f"))))))
  
  (define-macro define-label
    (lambda (msg parent)
      `(instantiate message% (,msg ,parent null +font+ #t 2 2 +left-width+))))
  
  (define-macro define-msg
    (lambda (msg parent)
      `(instantiate message% (,msg ,parent))))
  
  (define-macro define-handler
    (lambda (name)
      `(define/public (,(string->symbol (string-append "set-" (symbol->string name)))
                        fn)
         (set! ,name fn))))
  
  (define-macro define-handled-fn
    (lambda (name)
      `(begin (define (,name) (void))
              (define-handler ,name)))))